<script setup lang="ts">
import More from '~/components/More/index.vue'
import ContentTitle from '~/components/ContentTitle/index.vue'
import ItemStyle from '~/components/ItemStyle/index.vue'

interface Props {
    type: 'Picture' | 'Music' | 'Font' | 'Video'
}

const list = inject<any>('activityList')

const $props = defineProps<Props>()
const $router = useRouter()

const loading = shallowRef<boolean>(false)

function handleJumpActivityMore() {
    $router.push({
        path: '/activity-more',
        query: {
            type: $props.type
        }
    })
}

function handleJumpActivity(id: number) {
    window.open($router.resolve(`/activity-details/${id}`).href, '_blank')
}

</script>

<template>
    <div class="activity">
        <div class="title">
            <ContentTitle title="活动" englishTitle="ACTIVITY" />
            <More title="更多活动" @click="handleJumpActivityMore" />
        </div>
        <div v-loading="loading">
            <el-empty class="empty" description="暂无内容" v-if="list.length == 0" :image-size="82" />
            <div class="content">
                <ItemStyle v-for="item in list" :key="item.id" :type="1" :title="item.title" :image="item.image"
                    @on-click-practice="handleJumpActivity(item.id)" />
            </div>
        </div>
    </div>
</template>

<style lang="less" scoped>
.activity {
    box-sizing: border-box;
    width: 1310px;
    padding: 0 20px;
    margin: 0 auto;

    .title {
        display: flex;
        justify-content: space-between;
        align-items: center;
        position: relative;
        margin: 28px 0;
    }


    .content {
        display: grid;
        grid-template-columns: 1fr 1fr 1fr 1fr;
        justify-content: space-between;
        gap: 33px 20px;
    }
}
</style>